Skip to content

feat: add auth can I operation - #12

Merged
matzew merged 1 commit into
mcpchecker:mainfrom
Cali0707:add-auth-cani-operation
Feb 3, 2026
Merged

feat: add auth can I operation#12
matzew merged 1 commit into
mcpchecker:mainfrom
Cali0707:add-auth-cani-operation

Conversation

@Cali0707

@Cali0707 Cali0707 commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

This PR adds support for checking Auth for a user (to enable testing RBAC configurations)

Summary by CodeRabbit

Release Notes

  • New Features

    • Added RBAC permission verification capability enabling users to check whether specific users have access to Kubernetes resources and actions with configurable parameters (verb, resource, namespace, API group, and resource name).
  • Chores

    • Updated dependencies to support Kubernetes API v0.35.0 and related tooling.

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Cali0707 requested review from a team and matzew February 2, 2026 20:59
@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request implements Kubernetes permission checking via a new "authCanI" operation. Changes include adding dependencies, creating a handler and tests for the operation, extending the resource client with SubjectAccessReview-based authorization checks, initializing an authorization client, and registering the operation.

Changes

Cohort / File(s) Summary
Dependency Updates
go.mod
Added k8s.io/api v0.35.0 as direct dependency; expanded indirect dependencies with OpenAPI SWAG packages, protobuf, YAML, and JSON patching libraries.
Authorization Handler
pkg/extension/authcani.go, pkg/extension/authcani_test.go
Implemented handleAuthCanI method to process permission checks with comprehensive test coverage; validates required parameters (verb, resource, as), invokes authorization client, supports optional expectation matching.
Client Extension
pkg/extension/client.go, pkg/extension/extension.go, pkg/extension/mock_client_test.go
Added CheckAccess method to ResourceClient interface; implemented SubjectAccessReview-based check in dynamicClientAdapter; initialized authorization v1 client in extension setup; added checkAccessFn to mock client for testing.
Operation Registration
pkg/extension/operations.go
Registered new "authCanI" operation with JSON schema defining parameters (verb, resource, as, namespace, apiGroup, resourceName, expect) and wired to handleAuthCanI handler.

Sequence Diagram

sequenceDiagram
    participant User as User/Client
    participant Handler as handleAuthCanI
    participant Client as ResourceClient
    participant K8s as Kubernetes API

    User->>Handler: OperationRequest (verb, resource, as, namespace, etc.)
    Handler->>Handler: Validate required parameters
    Handler->>Client: CheckAccess(user, verb, resource, apiGroup, namespace, resourceName)
    Client->>K8s: Create SubjectAccessReview
    K8s-->>Client: SubjectAccessReview result (Allowed, Reason)
    Client-->>Handler: (allowed bool, reason string, error)
    Handler->>Handler: Check against expect (if provided)
    Handler-->>User: OperationResult (Success with allowed/reason outputs)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 Hop-hop, now we check who can do what,
SubjectAccessReviews in each Kubernetes slot!
With verbs and resources and namespaces tight,
Permissions are verified—auth checks done right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add auth can I operation' directly and clearly summarizes the main change: adding a new 'authCanI' operation to enable RBAC permission checking.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@nader-ziada

Copy link
Copy Markdown

LGTM

tests still running

@Cali0707

Cali0707 commented Feb 2, 2026

Copy link
Copy Markdown
Contributor Author

Job is about to start running on the hosted runner: GitHub Actions 1000000179
Job is waiting for a hosted runner to come online.
Requested labels: ubuntu-latest
Job defined at: mcpchecker/kubernetes-extension/.github/workflows/test.yaml@refs/pull/12/merge
Waiting for a runner to pick up this job...
Requested labels: ubuntu-latest
Job defined at: mcpchecker/kubernetes-extension/.github/workflows/test.yaml@refs/pull/12/merge
Waiting for a runner to pick up this job...

Seems like github actions is struggling...

@matzew matzew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matzew
matzew merged commit 69c50a6 into mcpchecker:main Feb 3, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants